//
//  ApplyMedicineNoteCell.m
//  KMedicine
//
//  Created by 曹牧 on 16/7/6.
//  Copyright © 2016年 caomu. All rights reserved.
//

#import "ApplyMedicineNoteCell.h"



@interface ApplyMedicineNoteCell()

@property (nonatomic,weak) UILabel * nameLabel;
@property (nonatomic,weak) UILabel * disLabel;
@property (nonatomic,weak) UILabel * timeLabel;

@property (nonatomic,weak) UIView  * lineView;

@property (nonatomic,weak) UILabel * docLabel;
@property (nonatomic,weak) UILabel * dutyLabel;
@property (nonatomic,weak) UILabel * hospitalLabel;

@property (nonatomic,weak) UIButton * auditBtn;
@property (nonatomic,weak) UIImageView * arrow;

@end

@implementation ApplyMedicineNoteCell

#pragma mark -
#pragma mark - setter
- (void)setModel:(ApplyMedicineNoteModel *)model{
    _model = model;
    
    [self setupUI];
    
}

- (void)setupUI{
    
    //line
    UIView * lineView = [[UIView alloc] init];
    lineView.backgroundColor = kThemeColor;
    self.lineView = lineView;
    [self.contentView addSubview:lineView];
    
    //button
    UIButton * auditBtn = [[UIButton alloc] init];
    [auditBtn setTitle:self.model.audiStatus forState:UIControlStateNormal];
    [auditBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    auditBtn.layer.cornerRadius = 35;
    auditBtn.layer.masksToBounds = YES;
    [auditBtn setBackgroundColor:kThemeColor];
    self.auditBtn = auditBtn;
    [self.contentView addSubview:auditBtn];
    
    //arrow
    UIImageView * arrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_right_black"]];
    self.arrow = arrow;
    [self.contentView addSubview:arrow];
    
    
    
    //name
    UILabel * nameLabel = [[UILabel alloc] init];
    nameLabel.text = self.model.patientName;
    [nameLabel sizeToFit];
    self.nameLabel = nameLabel;
    [self.contentView addSubview:nameLabel];
    
    
    //dis
    
    UILabel * disLabel = [[UILabel alloc] init];
    disLabel.text = self.model.disease;
    [disLabel sizeToFit];
    self.disLabel = disLabel;
    [self.contentView addSubview:disLabel];
    
    //time
    UILabel * timeLabel = [[UILabel alloc] init];
    timeLabel.text = self.model.look_time;
    [timeLabel sizeToFit];
    self.timeLabel = timeLabel;
    [self.contentView addSubview:timeLabel];
    
    //doctor
    UILabel * docLabel = [[UILabel alloc] init];
    docLabel.text = self.model.medicine;
    [docLabel sizeToFit];
    self.docLabel = docLabel;
    [self.contentView addSubview:docLabel];
    
    //duty
    UILabel * dutyLabel = [[UILabel alloc] init];
    dutyLabel.text = self.model.medicineDuty;
    [dutyLabel sizeToFit];
    self.dutyLabel = dutyLabel;
    [self.contentView addSubview:dutyLabel];
    
    //address
    UILabel * hospitalLabel = [[UILabel alloc] init];
    hospitalLabel.text = self.model.hospitalName;
    [hospitalLabel sizeToFit];
    self.hospitalLabel = hospitalLabel;
    [self.contentView addSubview:hospitalLabel];
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    //line
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(CGSizeMake(270, 2));
        make.left.equalTo(self.contentView).offset(5);
        make.top.equalTo(self.contentView.bounds.size.height*0.5);
    }];
    
    //button
    [self.auditBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.equalTo(CGSizeMake(70, 70));
        make.centerY.equalTo(self.lineView.centerY);
        make.left.equalTo(self.lineView.right);
    }];
    
    //arrow
    [self.arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.auditBtn.right).offset(10);
        make.centerY.equalTo(self.auditBtn.centerY);
        
    }];
    
    //name
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.offset(20);
        make.bottom.equalTo(self.lineView.top).offset(-10);
        
    }];
    //dis
    
    [self.disLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.right).offset(20);
        make.bottom.equalTo(self.nameLabel.bottom);
    }];
    
    //time
    [self.timeLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.disLabel.right).offset(20);
        make.bottom.equalTo(self.disLabel.bottom);
    }];
    
    //doctor
    
    [self.docLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self.nameLabel);
        make.top.equalTo(self.lineView).offset(10);
    }];
    
    //duty
    [self.dutyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.docLabel.right).offset(10);
        make.top.equalTo(self.docLabel);
    }];
    
    //hospital
    
    [self.hospitalLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dutyLabel.right).offset(20);
        make.top.equalTo(self.dutyLabel);
    }];
}

@end
